// Singleton.h: interface for the Singleton class.
//
//////////////////////////////////////////////////////////////////////

#ifndef __CSINGLETON_H__
#define __CSINGLETON_H__

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000



template <typename T>
class CSingleton
{
public:
	~CSingleton()
	{

	}

	static T * Instance()
	{
		if (0 == ms_pInstance)
		{
			ms_pInstance = new T;
		}

		return ms_pInstance;
	}
	static T * getSingleton()
	{
		if (0 == ms_pInstance)
		{
			ms_pInstance = new T;
		}

		return ms_pInstance;
	}
	static void destroyInstance()
	{
		if (ms_pInstance) {		
			delete ms_pInstance;
			ms_pInstance = 0;
		}
	}

public:

	static T *		ms_pInstance;
};

template< class T > T * CSingleton<T>::ms_pInstance = 0;




#endif // __SINGLETON_H__
